﻿using System.ComponentModel;
using System.Web.UI;

namespace OF.Controls
{
    /// <summary>
    /// 文件名称：复选框控件
    /// </summary>
    [DefaultProperty("Text"), ToolboxData("<{0}:OFCheckBox runat=server></{0}:OFCheckBox>")]
    public class OFCheckBox : System.Web.UI.WebControls.CheckBox, ISearcher
    {
        #region sql搜索条件接口的实现
        /// <summary>
        /// 获取或设置sql条件字段
        /// </summary>
        [Bindable(false), Category("Behavior"), DefaultValue(""), Description("获取或设置sql条件字段。")]
        public string SqlField
        {
            get
            {
                object o = ViewState["SqlField"];
                return (o == null) ? "" : o.ToString();
            }
            set
            {
                ViewState["SqlField"] = value;
            }
        }
        /// <summary>
        /// 获取或设置sql条件关系符
        /// </summary>
        [Bindable(false), Browsable(false), Category("Behavior"), DefaultValue(""), TypeConverter(typeof(CharacterTypeConverter)), Description("获取或设置sql条件关系符。")]
        public string SqlCharacter
        {
            get
            {
                return "等于";
            }
            set
            {
            }
        }
        /// <summary>
        /// 获取搜索条件语句
        /// </summary>
        /// <returns></returns>
        public string GetSqlWhere()
        {
            string value = Checked ? "1" : "0";
            return SqlField + " = " + value;
        }
        /// <summary>
        /// 获取当前控件的ID
        /// </summary>
        /// <returns></returns>
        public string GetControlId()
        {
            return ID;
        }
        /// <summary>
        /// 获取或设置搜索分组
        /// </summary>
        [Bindable(false), Category("Behavior"), DefaultValue(""), Description("获取或设置sql搜索分组。")]
        public string SearcherGroupName
        {
            get
            {
                object o = ViewState["SearcherGroupName"];
                return (o == null) ? "" : o.ToString();
            }
            set
            {
                ViewState["SearcherGroupName"] = value;
            }
        }
        #endregion
    }
}
